package org.example.rabbitmq.provider;

import org.example.rabbitmq.provider.mq.RabbitMqManager;
import org.example.rabbitmq.provider.notify.QueueCreatedNotifier;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class DynamicQueueProviderApplication {
    public static void main(String[] args) {
        SpringApplication.run(DynamicQueueProviderApplication.class, args);
    }

    @Bean
    public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
        return new RabbitAdmin(connectionFactory);
    }

    @Bean
    public DirectExchange messageExchange() {
        return new DirectExchange(RabbitMqManager.EXCHANGE_NAME, true, false);
    }

    @Bean
    public FanoutExchange notifyExchange() {
        return new FanoutExchange(QueueCreatedNotifier.NOTIFY_EXCHANGE_NAME, true, false);
    }
}